Claude Code Integration
Codeflash integrates natively with Claude Code through specialized subagents - dedicated AI assistants that provide comprehensive Python performance optimization capabilities directly within your development workflow.π Quick Setup
1. Install Codeflash
2. Integrate with Claude Code
3. Restart Claude Code
After setup, restart Claude Code to load the new MCP server.β¨ Three Specialized Subagents
Codeflash provides three dedicated subagents, each with specialized expertise:π @codeflash-optimizer - AI-Powered Optimization
The primary optimization specialist that implements performance improvements:- Function and file-level optimization (2-55x speedups)
- End-to-end script tracing and optimization
- Algorithm improvements and efficiency gains
- Project setup and CI/CD integration
π @codeflash-profiler - Performance Analysis
Expert in identifying bottlenecks and analyzing performance patterns:- Execution tracing and hotspot identification
- Performance benchmarking and statistical analysis
- Memory usage analysis and optimization recommendations
- Scalability assessment and bottleneck prioritization
ποΈ @codeflash-reviewer - Performance Code Reviews
Specialized in reviewing code for performance issues during development:- Algorithmic efficiency analysis (time/space complexity)
- Performance anti-pattern detection
- Library usage optimization recommendations
- Code review integration with performance focus
π§ Available MCP Tools
The integration provides these tools that Claude Code can use:| Tool | Description |
|---|---|
optimize_function | Optimize a specific function by name |
optimize_file | Optimize all functions in a file |
trace_and_optimize | Trace script execution and optimize |
optimize_from_replay_tests | Use test files to guide optimization |
optimize_all_functions | Optimize entire project (use with caution) |
initialize_project | Set up codeflash in a project |
setup_github_actions | Configure CI/CD optimization |
verify_installation | Test that codeflash works correctly |
run_benchmarks | Execute performance benchmarks |
get_codeflash_status | Check current project setup |
get_optimization_help | Get usage help and best practices |
π Usage Examples
Basic Optimization
End-to-End Script Optimization
Project Setup
βοΈ Configuration
Manual Setup
If automatic setup doesnβt work, you can manually add codeflash to your Claude Code configuration:-
Find your Claude Code config file:
- macOS:
~/.claude/config.jsonor~/Library/Application Support/Claude Code/config.json - Linux:
~/.config/claude/config.json - Windows:
%APPDATA%/Claude Code/config.json
- macOS:
- Add the MCP server configuration:
Verification
Check if the integration is working:π Troubleshooting
Common Issues
βcodeflash-mcp command not found"
"MCP server failed to start"
"Claude Code doesnβt recognize codeflashβ
- Ensure Claude Code is restarted after setup
- Check config file exists and is valid JSON
- Verify MCP server path is correct
Debug Commands
π― Best Practices
Optimization Workflow
- Start Small: Begin with single function optimization
- Use Tracing: For end-to-end scripts, use trace-based optimization
- Review Changes: Always review optimizations before merging
- Benchmark: Use benchmarking to measure improvements
- Iterative: Optimize iteratively rather than all at once
Claude Code Tips
- Be specific about which functions/files to optimize
- Ask for explanations of optimizations made
- Request benchmarking to validate improvements
- Use natural language - Claude Code understands context
Performance Considerations
- Large project optimization can take significant time
- Use
--no-prflag for local-only testing - Set up GitHub Actions for continuous optimization
π Advanced Usage
Custom Workflows
Integration with CI/CD
Performance Analysis
π Learn More
Codeflash Claude Code integration brings AI-powered code optimization directly into your development workflow, making performance improvements as easy as asking for them.